﻿namespace WMS6.Web
{
    using System;
    using System.Collections.Generic;
    using System.Data;
    using System.Web;
    using WMS6.Web.CommonMethodServiceRef;

    public class CommoneMethodServiceClientProxy : BasePage
    {
        public string CreatedLocation(CreatedLocationinfo CreateLocation, LocationInfo Location)
        {
            PubParasInfo pubParasInfo = this.InitPubParasInfo();
            using (CommonMethodServiceClient client = new CommonMethodServiceClient("WSHttpBinding_ICommonMethodService"))
            {
                return client.CreatedLocation(CreateLocation, Location, pubParasInfo);
            }
        }

        public string DeleteCustGridviewInfos(string functionID, string gridviewID)
        {
            PubParasInfo pubParasInfo = this.InitPubParasInfo();
            using (CommonMethodServiceClient client = new CommonMethodServiceClient("WSHttpBinding_ICommonMethodService"))
            {
                return client.DeleteCustGridviewInfos(functionID, gridviewID, pubParasInfo);
            }
        }

        public List<AppSettingInfo> GetAllAppSettingInfo()
        {
            using (CommonMethodServiceClient client = new CommonMethodServiceClient("WSHttpBinding_ICommonMethodService"))
            {
                return client.GetAllAppSettingInfo();
            }
        }

        public List<VisualLocationInfo> GetAllVisualLocationInfo(VisualLocationQueryEntity VisualocQuery)
        {
            PubParasInfo pubParasInfo = this.InitPubParasInfo();
            using (CommonMethodServiceClient client = new CommonMethodServiceClient("WSHttpBinding_ICommonMethodService"))
            {
                return client.GetAllVisualLocationInfo(VisualocQuery, pubParasInfo);
            }
        }

        public AppRegInfo GetAppRegInfo()
        {
            PubParasInfo pubParasInfo = new PubParasInfo {
                UserID = "DBA",
                UserLanguage = "zh-CN",
                CurrentWH = "10"
            };
            using (CommonMethodServiceClient client = new CommonMethodServiceClient("WSHttpBinding_ICommonMethodService"))
            {
                return client.GetAppRegInfo(pubParasInfo);
            }
        }

        public List<OwnerInfo> GetAuthorizedOwnerByUserID()
        {
            PubParasInfo pubParasInfo = this.InitPubParasInfo();
            using (CommonMethodServiceClient client = new CommonMethodServiceClient("WSHttpBinding_ICommonMethodService"))
            {
                return client.GetAuthorizedOwnerByUserID(pubParasInfo.UserID, pubParasInfo);
            }
        }

        public int GetAvailableQty(string ownerID, string skuID)
        {
            PubParasInfo pubParasInfo = this.InitPubParasInfo();
            using (CommonMethodServiceClient client = new CommonMethodServiceClient("WSHttpBinding_ICommonMethodService"))
            {
                return client.GetAvailableQty(ownerID, skuID, pubParasInfo);
            }
        }

        public List<CartonGroup4DDL> GetCartonGroup4Select()
        {
            PubParasInfo pubParasInfo = this.InitPubParasInfo();
            using (CommonMethodServiceClient client = new CommonMethodServiceClient("WSHttpBinding_ICommonMethodService"))
            {
                return client.GetCartonGroup4Select(pubParasInfo);
            }
        }

        public List<CustGridviewInfo> GetCustGridviewInfos(string functionID, string gridviewID)
        {
            PubParasInfo pubParasInfo = this.InitPubParasInfo();
            using (CommonMethodServiceClient client = new CommonMethodServiceClient("WSHttpBinding_ICommonMethodService"))
            {
                return client.GetCustGridviewInfos(functionID, gridviewID, pubParasInfo);
            }
        }

        public List<CycleCountRule4DDL> GetCycleCountRule4Select()
        {
            PubParasInfo pubParasInfo = this.InitPubParasInfo();
            using (CommonMethodServiceClient client = new CommonMethodServiceClient("WSHttpBinding_ICommonMethodService"))
            {
                return client.GetCycleCountRule4Select(pubParasInfo);
            }
        }

        public List<FieldNameInfo> GetFieldNameByTableName(string TableName)
        {
            PubParasInfo pubParasInfo = this.InitPubParasInfo();
            using (CommonMethodServiceClient client = new CommonMethodServiceClient("WSHttpBinding_ICommonMethodService"))
            {
                return client.GetFieldNameByTableName(TableName, pubParasInfo);
            }
        }

        public DataSet GetInitGridViewInfoByQueryEntity(InitGridviewQueryEntity initGridviewQuery)
        {
            PubParasInfo pubParasInfo = this.InitPubParasInfo();
            using (CommonMethodServiceClient client = new CommonMethodServiceClient("WSHttpBinding_ICommonMethodService"))
            {
                return client.GetInitGridViewInfoByQueryEntity(initGridviewQuery, pubParasInfo);
            }
        }

        public List<InitGridviewInfo> GetInitGridviewInfos(string functionID, string gridviewID)
        {
            PubParasInfo pubParasInfo = this.InitPubParasInfo();
            using (CommonMethodServiceClient client = new CommonMethodServiceClient("WSHttpBinding_ICommonMethodService"))
            {
                return client.GetInitGridviewInfos(functionID, gridviewID, pubParasInfo);
            }
        }

        public static CommoneMethodServiceClientProxy GetInstance()
        {
            return new CommoneMethodServiceClientProxy();
        }

        public DataSet GetInvSkuQtyByOwnerID(string OwnerID)
        {
            PubParasInfo pubParasInfo = this.InitPubParasInfo();
            using (CommonMethodServiceClient client = new CommonMethodServiceClient("WSHttpBinding_ICommonMethodService"))
            {
                return client.GetInvSkuQtyByOwnerID(OwnerID, pubParasInfo);
            }
        }

        public List<LotAttributeCodeInfo> GetLotAttributCodeByGroupID(string GroupID)
        {
            PubParasInfo pubParasInfo = this.InitPubParasInfo();
            using (CommonMethodServiceClient client = new CommonMethodServiceClient("WSHttpBinding_ICommonMethodService"))
            {
                return client.GetLotAttributCodeByGroupID(GroupID, pubParasInfo);
            }
        }

        public List<string> GetLotAttributeCode4LotTemplate()
        {
            PubParasInfo pubParasInfo = this.InitPubParasInfo();
            using (CommonMethodServiceClient client = new CommonMethodServiceClient("WSHttpBinding_ICommonMethodService"))
            {
                return client.GetLotAttributeCode4LotTemplate(pubParasInfo);
            }
        }

        public List<LotTemplate4DDL> GetLotTemplate4Select()
        {
            PubParasInfo pubParasInfo = this.InitPubParasInfo();
            using (CommonMethodServiceClient client = new CommonMethodServiceClient("WSHttpBinding_ICommonMethodService"))
            {
                return client.GetLotTemplate4Select(pubParasInfo);
            }
        }

        public LotTemplateInfo GetLotTemplateInfo(string SkuID, string OwnerID)
        {
            PubParasInfo pubParasInfo = this.InitPubParasInfo();
            using (CommonMethodServiceClient client = new CommonMethodServiceClient("WSHttpBinding_ICommonMethodService"))
            {
                return client.GetAttributeInfoBySkuID(SkuID, OwnerID, pubParasInfo);
            }
        }

        public List<PreferenceValueInfo> GetPreferenceValueByID(string preferenceID)
        {
            using (CommonMethodServiceClient client = new CommonMethodServiceClient("WSHttpBinding_ICommonMethodService"))
            {
                return client.GetPreferenceValueByID(preferenceID);
            }
        }

        public List<ReceiptValidation4DDL> GetReceiptValidation4Select()
        {
            PubParasInfo pubParasInfo = this.InitPubParasInfo();
            using (CommonMethodServiceClient client = new CommonMethodServiceClient("WSHttpBinding_ICommonMethodService"))
            {
                return client.GetReceiptValidation4Select(pubParasInfo);
            }
        }

        public DataSet GetRelatedOrders(string Type, string skuID, string ownerID, string lot, string loc, string lpn)
        {
            PubParasInfo pubParasInfo = this.InitPubParasInfo();
            using (CommonMethodServiceClient client = new CommonMethodServiceClient("WSHttpBinding_ICommonMethodService"))
            {
                return client.GetRelatedOrders(Type, skuID, ownerID, lot, loc, lpn, pubParasInfo);
            }
        }

        public List<Rule4DDL> GetRules4Select(string ruleID)
        {
            PubParasInfo pubParasInfo = this.InitPubParasInfo();
            using (CommonMethodServiceClient client = new CommonMethodServiceClient("WSHttpBinding_ICommonMethodService"))
            {
                return client.GetRules4Select(ruleID, pubParasInfo);
            }
        }

        public SkuInfo GetSkuByBarcode(string Barcode)
        {
            PubParasInfo pubParasInfo = this.InitPubParasInfo();
            using (CommonMethodServiceClient client = new CommonMethodServiceClient("WSHttpBinding_ICommonMethodService"))
            {
                return client.GetSkuByBarcode(Barcode, pubParasInfo);
            }
        }

        public SkuInfo GetSkuInfoByUserOwner(string skuID, string userID)
        {
            PubParasInfo pubParasInfo = this.InitPubParasInfo();
            using (CommonMethodServiceClient client = new CommonMethodServiceClient("WSHttpBinding_ICommonMethodService"))
            {
                return client.GetSkuInfoByUserOwner(skuID, userID, pubParasInfo);
            }
        }

        public List<SysCode4DDL> GetSysCode4DDL()
        {
            PubParasInfo pubParasInfo = this.InitPubParasInfo();
            using (CommonMethodServiceClient client = new CommonMethodServiceClient("WSHttpBinding_ICommonMethodService"))
            {
                return client.GetSysCode4DDL(pubParasInfo);
            }
        }

        public List<SysCode4DDL> GetSysCodeDataSource(string codeType)
        {
            PubParasInfo pubParasInfo = this.InitPubParasInfo();
            string language = base.UserInfo.Preference.Lang;
            using (CommonMethodServiceClient client = new CommonMethodServiceClient("WSHttpBinding_ICommonMethodService"))
            {
                return client.GetSysCodeForDropDownList(codeType, language, pubParasInfo);
            }
        }

        public List<UomList> GetUomListByPackID(string packID)
        {
            PubParasInfo pubParasInfo = this.InitPubParasInfo();
            using (CommonMethodServiceClient client = new CommonMethodServiceClient("WSHttpBinding_ICommonMethodService"))
            {
                return client.GetUomListByPackID(packID, pubParasInfo);
            }
        }

        public List<WareHouseName4DDL> GetUserPermissionWareHouse()
        {
            PubParasInfo pubParasInfo = this.InitPubParasInfo();
            using (CommonMethodServiceClient client = new CommonMethodServiceClient("WSHttpBinding_ICommonMethodService"))
            {
                return client.GetUserPermissionWareHouse(pubParasInfo.UserID);
            }
        }

        public List<WareHouseName4DDL> GetWareHouseDataSource()
        {
            using (CommonMethodServiceClient client = new CommonMethodServiceClient("WSHttpBinding_ICommonMethodService"))
            {
                return client.GetWareHouse4Select();
            }
        }

        public string ImportByData(List<List<string>> ImportByData, string IsUpdate, string dataName)
        {
            PubParasInfo pubParasInfo = this.InitPubParasInfo();
            using (CommonMethodServiceClient client = new CommonMethodServiceClient("WSHttpBinding_ICommonMethodService"))
            {
                return client.ImportByData(ImportByData, dataName, IsUpdate, pubParasInfo);
            }
        }

        public string ImportByDataSet(DataSet ds, string dataName)
        {
            PubParasInfo pubParasInfo = this.InitPubParasInfo();
            using (CommonMethodServiceClient client = new CommonMethodServiceClient("WSHttpBinding_ICommonMethodService"))
            {
                return client.ImportByDataSet(ds, dataName, pubParasInfo);
            }
        }

        private PubParasInfo InitPubParasInfo()
        {
            if (base.UserInfo != null)
            {
                return new PubParasInfo { UserID = base.UserInfo.UserID, UserLanguage = base.UserInfo.Preference.Lang, CurrentWH = base.UserInfo.CurrentWH };
            }
            HttpContext.Current.Response.Redirect("../Login.aspx?from=Logout", true);
            return null;
        }

        public string InsertCustGridviewInfos(List<CustGridviewInfo> custGridviewInfo)
        {
            PubParasInfo pubParasInfo = this.InitPubParasInfo();
            using (CommonMethodServiceClient client = new CommonMethodServiceClient("WSHttpBinding_ICommonMethodService"))
            {
                return client.InsertCustGridviewInfos(custGridviewInfo, pubParasInfo);
            }
        }

        public string LpnGenerateByGenerateType(LPNGenParams lpnGenParams)
        {
            PubParasInfo pubParasInfo = this.InitPubParasInfo();
            using (CommonMethodServiceClient client = new CommonMethodServiceClient("WSHttpBinding_ICommonMethodService"))
            {
                return client.LpnGenerateByGenerateType(lpnGenParams, pubParasInfo);
            }
        }

        public DataSet SearchDataByKey(string key, string key2, string type)
        {
            PubParasInfo pubParasInfo = this.InitPubParasInfo();
            using (CommonMethodServiceClient client = new CommonMethodServiceClient("WSHttpBinding_ICommonMethodService"))
            {
                return client.SearchDataByKey(key, key2, type, pubParasInfo);
            }
        }

        public string SqlAnalyse(string strSql)
        {
            PubParasInfo pubParasInfo = this.InitPubParasInfo();
            using (CommonMethodServiceClient client = new CommonMethodServiceClient("WSHttpBinding_ICommonMethodService"))
            {
                return client.SqlAnalyse(strSql, pubParasInfo);
            }
        }

        public DataSet SqlQuery(string sql, BaseQuery baseQuery)
        {
            using (CommonMethodServiceClient client = new CommonMethodServiceClient("WSHttpBinding_ICommonMethodService"))
            {
                return client.SqlQuery(sql, baseQuery);
            }
        }

        public string UpdateAuditDefinitionInfoByList(List<AuditDefinitionInfo> objs)
        {
            PubParasInfo pubParasInfo = this.InitPubParasInfo();
            using (CommonMethodServiceClient client = new CommonMethodServiceClient("WSHttpBinding_ICommonMethodService"))
            {
                return client.UpdateAuditDefinitionInfoByList(objs, pubParasInfo);
            }
        }

        public string UpdateRegID(string regIDValue)
        {
            PubParasInfo pubParasInfo = new PubParasInfo {
                UserID = "DBA",
                UserLanguage = "zh-CN",
                CurrentWH = "10"
            };
            using (CommonMethodServiceClient client = new CommonMethodServiceClient("WSHttpBinding_ICommonMethodService"))
            {
                return client.UpdateRegID(regIDValue, pubParasInfo);
            }
        }

        public string UpdateUDF(string ID, UDFInfo udfInfo, string strType)
        {
            PubParasInfo pubParasInfo = this.InitPubParasInfo();
            using (CommonMethodServiceClient client = new CommonMethodServiceClient("WSHttpBinding_ICommonMethodService"))
            {
                return client.UpdateUDF(ID, udfInfo, strType, pubParasInfo);
            }
        }
    }
}

